package com.dayuanit.dy15.lesson22.demo2;

import java.util.Comparator;

/**
 * 小狗的比较器
 * 按照价格进行比较
 */
public class DogCompartor implements Comparator {

    @Override
    public int compare(Object o1, Object o2) {
        Dog dog1 = (Dog)o1;
        Dog dog2 = (Dog)o2;
        //从小到大
//        return dog1.price - dog2.price;

        //从大到小
        return dog2.price - dog1.price;
    }
}
